package cn.itsource.ymcc.web.controller;

import cn.itsource.ymcc.constant.Constants;
import cn.itsource.ymcc.domain.SmsCodeVo;
import cn.itsource.ymcc.result.JsonResult;
import cn.itsource.ymcc.service.ICommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/verifycode")
public class CommonController {
    @Autowired
    private ICommonService iCommonService;

    @GetMapping("/imageCode/{imageCodeKey}")
    public JsonResult imageCode(@PathVariable("imageCodeKey") String imageCodeKey){
        return iCommonService.imageCode(imageCodeKey+ Constants.REGISTER);
    }

    @PostMapping("/sendSmsCode")
    public JsonResult sendSmsCode(@RequestBody @Valid SmsCodeVo smsCodeVo){
        return iCommonService.sendSmsCode(smsCodeVo);
    }
}
